﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using YJKArchUtils.Utils;

namespace YJKRevitDimensionText.OneKeyPlanDim.LevelDim
{
	public class RoomComparer : IComparer<Room>
	{
		public int Compare(Room Room1, Room Room2)
		{
			if (Geometry.LessThan(Room1.Area, Room2.Area))
			{
				return 1;
			}
			if (Geometry.LessThan(Room1.Area, Room2.Area))
			{
				return -1;
			}
			LocationPoint locationPoint = Room1.Location as LocationPoint;
			LocationPoint locationPoint2 = Room2.Location as LocationPoint;
			if (locationPoint == null || locationPoint2 == null)
			{
				return 0;
			}
			if (Geometry.LessThan(locationPoint.Point.Y, locationPoint2.Point.Y))
			{
				return -1;
			}
			if (!Geometry.LessThan(locationPoint.Point.Y, locationPoint2.Point.Y))
			{
				return 1;
			}
			if (Geometry.LessThan(locationPoint.Point.X, locationPoint2.Point.X))
			{
				return 1;
			}
			if (!Geometry.LessThan(locationPoint.Point.X, locationPoint2.Point.X))
			{
				return -1;
			}
			return 0;
		}
	}
}
